import requestProxy from '@/utils/request';

const { request } = requestProxy;

//  用户列表
export function getList(page, perPage, param) {
  return request({
    url: '/admin/user/list',
    method: 'get',
    params: {
      page,
      perPage,
      ...param
    }
  });
}
export function getUserList(params) {
  return request({
    url: '/admin/user/list',
    method: 'get',
    params
  });
}

// 获取系统所有的职位列表
export function getAllPost(params) {
  return request({
    url: '/admin/user/allPost',
    method: 'get',
    params
  });
}
// 新增用户
export function userCreate(data) {
  return request({
    url: '/admin/user/create',
    method: 'post',
    data
  });
}

// 编辑用户
export function userEdit(id, data) {
  return request({
    url: `/admin/user/${id}/edit`,
    method: 'put',
    data
  });
}

// 改变用户状态
export function changeStatus(id, params) {
  return request({
    url: `/admin/user/userstatus/${id}`,
    method: 'put',
    data: {
      userStatus: params.userStatus
    }
  });
}

// 用户 新建/编辑 部门下拉框
export function getDepartment() {
  return request({
    url: 'admin/user/deptList',
    method: 'get'
  });
}

// 审批人变更交接列表
export function queryHandoverList(params) {
  return request({
    url: '/admin/processManagement/handover/list',
    method: 'get',
    params
  });
}

// 查询用户是否拥有权限
export function userPermission(params) {
  return request({
    url: '/admin/user/permission',
    method: 'get',
    params
  });
}

export function getTransfereeCount(params) {
  return request({
    url: 'admin/handover/countList',
    method: 'get',
    params
  });
}

export function getRoleGroups(params) {
  return request({
    url: 'admin/user/roleGroup/list',
    method: 'get',
    params
  });
}

export function syncStructure(params) {
  return request({
    url: '/admin/user/syncStructure',
    method: 'get',
    params,
    timeout: 600000
  });
}
